﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using BusinessObject;
using System.IO;
namespace GreenLife.Admin
{
    public partial class ThemTinTuc : System.Web.UI.Page
    {
        NewsBO nBO = new NewsBO();
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void btnAddNew_Click(object sender, EventArgs e)
        {
            string imgFileName = Path.GetFileName(FileUploadControl.FileName);
            if (imgFileName.Equals("") == true)
            {
                imgFileName = "greenlifelogo.jpg";
            }
            else
            {
                FileUploadControl.SaveAs(Server.MapPath("~/imageUpload/") + imgFileName);
            }

            if (nBO.createNews(txtTitle.Text, txtQuickTitle.Text, "~/imageUpload/" + imgFileName, txtContent.Text,1))
            {
                Response.Redirect("DanhSachBanTin.aspx");
            }
            else
            {
                Response.Redirect("error.aspx");
            }
        }
    }
}